Technicalities
Signature Validationβ
The publisher fetches the prices every second for the required asset pairs from some off-chain oracle and stores it in the DB along with a signature. The keeper picks up tis data to then open/close the trades. The contract validates this data by generating a signature and checking if the signer is the publisher.
Settlement Fee (Sf)β
The contract defines the baseSettlementFeePercentageForAbove
and baseSettlementFeePercentageForBelow
.
Settlement Fee can be discounted by subtracting from the base sf.
This base max step reduction is defined in the BufferBinaryOptions
contracts based on referral mechanics.
- settlementFeePercentage =
- Settlement fee =
- For settlement fee of x%, the payout will be
- The lower the settlement fee, the higher is the payout the user receives
settlement fee is dynamic on Buffer, influenced by trading volume and payout.
Dynamic sf formula:
def calculate sf (
total_payin: float,
total_payout: float,
max_payout_for_market: float,
C_for_market: float,
initial_payout_for_market: float,
) -> int:
payout_percent = (
(C_for_market * (max_payout_for_market - initial_payout_for_market))
+ ((total_payout - total_payin) * 100)
) / (C_for_market + total_payin)
payout = min(max_payout_for_market, max_payout_for_market - payout_percent)
payout = int(payout) - (int(payout) % 5)
return to_sf(payout)
Referral Discountsβ
Referrals allow users to get fee discounts and earn rebates. The referral program has tier-based system to ensure referrers receive the rebates for the users they onboard to Buffer Finance. Anyone can create a tier 1 code while the admin has ability to upgrade the user's code to tier 2 or tier 3.
Mechanics:
-
Referral Code Usage: referees can utilize a referrer's referral code while performing trades on Buffer. This referral code is provided by the referrer and serves as a unique identifier.
-
Referee Benefits: Upon using a valid referral code, referees receive a discount on their trade amount. This incentive motivates referees to engage in trades and encourages then to join the platform through the referrer's invitation.
-
Referrer Benefits: Referrers are rewarded with a rebate for each successful referral. This encourages existing users to invite new users to the platform, thereby expanding the user base.
-
The
openTrade()
function, responsible for trade execution accepts a referral code as an argument. By passing the referral code to this function, referees become eligible for the associated discounts and referrers qualify for rebates. -
Settlement fee discount and increased payout: When a valid referral code is provided as an argument, to the
openTrades()
function, referees are granted a discount on he settlement fee for their trades which results in increased payout.
Advanced Settings:β
On the Frontend, the users can find an option to configure the slippage and partial fill.
Partial Fill:β
This opens a trade of the maximum possible value and refunds the rest of the fees back to the users. If the user tries to open a trade for more than what the pool allows, then contract will check if the allowPartialFill
tag is true.
Slippage:β
On Buffer Finance, slippage is used as the accepted price movement between when the user initiates the trade and when the trade is actually opened. The frontned is fetching the price feed from the price APIs (which take a median over multiple exchanges).
When the user opens the trade on the frontend (launching an initiateTrade
transaction), the price form the API is used. Then the keeper open the trade, it is here the price is provided for blockNumber`` where the
intiateTrade``` transaction was accepted.
We check the slippage to check if there is a difference between the price provided on the frontend and the price used by the keeper.